﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Vowei.Core.Models
{
    /// <summary>
    /// 所有的表都需要支持这个接口
    /// </summary>
    public interface ITable
    {
        /// <summary>
        /// 主键
        /// </summary>
        Guid ID { get; set; }
    }
    
    public interface INamedTable : ITable
    {        
        string Title { get; set; }
    }

    public interface IDuration : INamedTable
    {
        DateTime? StartDate { get; set; }

        DateTime? DueDate { get; set; }
    }

    public interface IRecursive : ITable
    {
        /// <summary>
        /// 重复任务的设置
        /// </summary>
        RecurrenceSetting RecurrenceSettings { get; set; }
    }

    public interface ISupportOws
    {
        int IdForOws { get; set; }
    }
    
    public interface IScoped
    {
        Milestone BelongsToMilestone { get; set; }

        Guid? BelongsToMilestoneId { get; set; }
    }

    /// <summary>
    /// 标记一个类型是否可以被评论
    /// </summary>
    public interface ITagable
    {
        /// <summary>
        /// 以分号分隔的标签
        /// </summary>
        string TagText { get; set; }
    }

    public interface ISupportDefaultProperties
    {
        DateTime? ClosedDate { get; set; }

        DateTime OpenDate { get; set; }

        DateTime LastModified { get; set; }

        string Reporter { get; set; }

        string LastModifiedBy { get; set; }
    }

    public interface ITableItemContainer
    {
        IQueryable Children { get; }
    }

    public interface IContainer<T> : ITableItemContainer
    {
        new List<T> Children { get; }
    }

    public interface IHasRelated<T>
    {
        List<T> RelatedTickets { get; }
    }

    public interface ICommentable : ITable
    {
        List<Comment> Comments { get; }
    }
    
    /// <summary>
    /// 在数据库中表示用户
    /// </summary>
    public interface IUser
    {
        /// <summary>
        /// 用户的用户名
        /// </summary>
        string UserName { get; }

        /// <summary>
        /// 用户的Email
        /// </summary>
        string Email { get; }
        
        /// <summary>
        /// 用户的显示名称
        /// </summary>
        string DisplayName { get; }

        /// <summary>
        /// 用于配合SharePoint的stssync协议的user-id属性，这个属性要求是一个唯一的数字
        /// </summary>
        int SharePointId { get; }

        string GetIdentifier();
    }
           
    public interface IStatus
    {
        string Status { get; set; }

        float Progress { get; set; }

        //void Close();

        //void ReActive();
    }

#if DEBUG
    public interface INewUserConfig
    {
        string UserName { get; set; }

        string Password { get; set; }

        string Email { get; set; }

        string PasswordQuestion { get; set; }

        string PasswordAnswer { get; set; }

        bool IsApproved { get; set; }
    }
#endif

    public interface IRepository<T> where T : class
    {
        IQueryable<T> Query { get; }

        IRepository<T> Include(string navigationProperty);

        void Add(T item);

        void Remove(T item);

        T Find(object key);

        T Attach(T entity);
    }

    public interface IVoweiContext
    {
        IRepository<Ticket> Tickets { get; }

        IRepository<Task> Tasks { get; }

        IRepository<Project> Projects { get; }

        IRepository<Milestone> Milestones { get; }

        IRepository<Requirement> Requirements { get; }

        IRepository<Comment> Comments { get; }

        IRepository<Tag> Tags { get; }

        IRepository<ChangeSet> ChangeSet { get; }

        IRepository<Permission> Permissions { get; }

        IRepository<PermissionSet> PermissionSet { get; }

        IRepository<Employee> Employees { get; }

        IRepository<Ace> Acl { get; }

        IRepository<Bug> Bugs { get; }

        IRepository<ResourceAssignment> Assignments { get; }

        IRepository<RecurrenceSetting> RecurrenceSettings { get; }

        IRepository<ResourceCalendar> ResourceCalendars { get; }

        IRepository<Resource> Resources { get; }

        int SaveChanges();

        IRepository<T> Resolve<T>() where T : class;

        ITicketStatusManager TicketStatusManager { get; }
    }
    
    public interface ITicketStatusManager
    {
        Dictionary<string, int> TaskStatusDefinitions { get; }

        void Cancel(Ticket ticket);

        void Accept(Ticket ticket);

        void Close(Ticket ticket);

        void Close(Ticket ticket, DateTime closeDate);

        void Complete(Ticket ticket);

        void ReActive(Ticket ticket);
    }

    public interface ICalendarException
    {
        List<ExceptionPeriod> Exceptions { get; }

        ICalendarException Except(ExceptionPeriod period);
    }

    public interface IExcelRowConvertable
    {
        bool IsExcelExtended { get; set; }

        string Description { get; set; }
    }
}
